#pragma once
#include "QString"
#include "QVector"
#include "sqlite3.h"

#ifndef DATABASE_H
#define DATABASE_H

struct WordResult {
    QString word;
    QString pronunciation;
    QString meaning;  // 去掉了wordType字段

    bool isValid() const {
        return !word.isEmpty();
    }
};

class database {
private:
    sqlite3* db;
    bool isOpen;

    bool openDatabase();
    void closeDatabase();

public:
    database();
    ~database();

    WordResult searchWord(const QString& word);
    QVector<QString> searchByPrefix(const QString& prefix, int limit = 10);
    QVector<QString> getNext20Words(const QString& prefix);
};

#endif // DATABASE_H